package com.happyfamily.springboot.crowdsourcingplatform.service.pan.impl;

import com.happyfamily.springboot.crowdsourcingplatform.base.result.Results;
import com.happyfamily.springboot.crowdsourcingplatform.dao.pan.DemandDao;
import com.happyfamily.springboot.crowdsourcingplatform.model.Need;
import com.happyfamily.springboot.crowdsourcingplatform.service.pan.DemandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author Administrator
 * @create 2020/02/26 11:02
 */
@Service
public class DemandServiceImpl implements DemandService
{
	@Autowired
	private DemandDao demandDao;

	@Override
	public Results<Need> getNeedBys(Integer offset, Integer limit)
	{
		return Results.success(demandDao.countAllNeeds().intValue(), demandDao.getAllNeedsByPage(offset, limit));

	}

	@Override
	public Results<Need> getNeedByFuzzyNeedTitle(String ntitle, String sname, Integer offset, Integer limit)
	{





		return Results.success(demandDao.getNeedByFuzzyNeedTitle(ntitle,sname).intValue(), demandDao.getNeedByFuzzyNeedNamePage(ntitle, sname, offset, limit));
	}







	@Override
	public Results<Need> getUserNeedBys(Integer offset, Integer limit, String account)
	{
		return Results.success(demandDao.getUserNeedByAccount(account).intValue(), demandDao.getUserNeedByPage(offset, limit,account));

	}

	@Override
	public Results<Need> getNeedByUserSearch(String ntitle, String sname, Integer offset, Integer limit, String account)
	{
		return Results.success(demandDao.getNeedByUserSearch(ntitle,sname,account).intValue(), demandDao.getSacherUserNeed(ntitle, sname,account, offset, limit));
	}
}
